package primetest.dto;

import java.util.ArrayList;
import java.util.List;


public class CreateWardWizardDto {
	private String buildingKey;
	private int departmentSeq;
	private int floor;
	private int wardCount;
	private String wardPrefix;
	private int wardIndexLength;
	private String bedPrefix;
	private int bedCount;
	private int wardStartIndex;
	private String extraInfo;
	private List<CheckCondition> conditions;

	public CreateWardWizardDto(String configStr) {
		reset(configStr);
	}

	public void reset(String configStr){
		buildingKey = "";
		floor = 1;
		wardCount = 1;
		wardPrefix = "";
		bedPrefix = "_";
		bedCount = 3;
		wardStartIndex = 1;
		wardIndexLength = -1;
		extraInfo = "";
		conditions = new ArrayList<CheckCondition>();
		for (String config : configStr.split("/")) {
			if (!config.equals("")) {
				String[] strs = config.split(":");
				CheckCondition con = new CheckCondition();
				con.term = strs[0];
				con.rendered = strs[1].equals("1");
				con.condition = false;
				if (con.rendered) {
					conditions.add(con);
				}
			}
		}
	}

	public String getBuildingKey() {
		return buildingKey;
	}

	public void setBuildingKey(String buildingKey) {
		this.buildingKey = buildingKey;
	}

	public int getFloor() {
		return floor;
	}

	public void setFloor(int floor) {
		this.floor = floor;
	}

	public int getWardCount() {
		return wardCount;
	}

	public void setWardCount(int wardCount) {
		this.wardCount = wardCount;
	}

	public String getWardPrefix() {
		return wardPrefix;
	}

	public void setWardPrefix(String wardPrefix) {
		this.wardPrefix = wardPrefix;
	}

	public int getBedCount() {
		return bedCount;
	}

	public void setBedCount(int bedCount) {
		this.bedCount = bedCount;
	}

	public int getWardStartIndex() {
		return wardStartIndex;
	}

	public void setWardStartIndex(int wardStartIndex) {
		this.wardStartIndex = wardStartIndex;
	}

	public List<CheckCondition> getConditions() {
		return conditions;
	}

	public void setConditions(List<CheckCondition> conditions) {
		this.conditions = conditions;
	}

	public Boolean[] getBooleanConditions() {
		Boolean[] r = new Boolean[conditions.size()];
		for (int i = 0; i < conditions.size(); i++) {
			r[i] = conditions.get(i).condition;
		}
		return r;
	}

	public static class CheckCondition {
		private String term;
		private boolean condition;
		private boolean rendered;
		public String getTerm() {
			return term;
		}
		public void setTerm(String term) {
			this.term = term;
		}
		public boolean isCondition() {
			return condition;
		}
		public void setCondition(boolean condition) {
			this.condition = condition;
		}
		public boolean isRendered() {
			return rendered;
		}
		public void setRendered(boolean rendered) {
			this.rendered = rendered;
		}

		public CheckCondition() {
		}
	}

	public boolean isValid() {
		// TODO Auto-generated method stub
		return true;
	}

	public String getBedPrefix() {
		return bedPrefix;
	}

	public void setBedPrefix(String bedPrefix) {
		this.bedPrefix = bedPrefix;
	}

	public int getWardIndexLength() {
		return wardIndexLength;
	}

	public void setWardIndexLength(int wardIndexLength) {
		this.wardIndexLength = wardIndexLength;
	}

	public int getDepartmentSeq() {
		return departmentSeq;
	}

	public void setDepartmentSeq(int departmentSeq) {
		this.departmentSeq = departmentSeq;
	}

	public String getExtraInfo() {
		return extraInfo;
	}

	public void setExtraInfo(String extraInfo) {
		this.extraInfo = extraInfo;
	}
}
